<?php
include("sessionUser.php");
include("Conexao.php");

$conexao = new Conexao();

$con = $conexao->conectBD();


$id = $_GET["id"];


$sql = "SELECT a.*,b.nome AS cat,c.nome AS fab,d.nome AS forn,e.nome AS loja,f.nome AS plat,g.nome AS jog,h.nome AS con FROM tbJogo_equipe05 a INNER JOIN tbCategoria_equipe05 b 
ON a.idCategoria=b.id INNER JOIN tbFabricante_equipe05 c ON a.idFabricante=c.id 
INNER JOIN  tbFornecedor d ON a.idFornecedor = d.codigo INNER JOIN tbLoja e ON a.idLoja = e.codigo
INNER JOIN tbPlataforma_equipe05 f ON a.idPlataforma = f.id INNER JOIN tbJogabilidade_equipe05 g ON a.idJogabilidade = g.id
INNER JOIN tbConectividade_equipe05 h ON a.idConectividade = h.id WHERE a.id = ".$id;
// seleciona o jogo com aquele id

$result = pg_query($sql);

$colum = pg_fetch_array($result, 0);


?>





<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <LINK REL=StyleSheet HREF="main.css" TYPE="text/css" MEDIA=screen>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta>   
        <link rel="stylesheet" href="main.css" />
    </head>
    <body>
           <strong> <h2>RECOMENDAR JOGO PARA AMIGOS </h2> </strong>
       
       <br><br>
       
       <table border="0" width="100%" align="center" style="border: 1px solid #ccc;">
            <tbody>
                <tr>
                    <td align="left" width="30%"><img src="fotosJogos/Fotos BD/<?echo $colum["imagempath"];?>" width="80" height="120" /></td>
                    <td width="70%">
                        <table border="0" width="100%" align="center" style="border: 1px solid #ccc;">
                             <tbody>
                                <tr>
                                    <td colspan="2">Nome: <?echo $colum["nome"];?></td>
                                   
                                </tr>
                                <tr>
                                    <td colspan="2">Descricao: <?echo $colum["descricao"];?></td>
                                </tr>
                             </tbody>
                        </table>

                        
                        
                        
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        
                        <?$sql = "SELECT nome,codigo FROM tbUsuario a , (SELECT idAmigo FROM tbAmigos_equipe05
                                    WHERE idUsuario = ".$_SESSION["id"]." ) b Where a.codigo = b.idAmigo  AND a.codigo  NOT IN 
                                    (SELECT idAmigo FROM tbRecomendacao_equipe05 WHERE idUsuario = ".$_SESSION["id"]." AND idJogo = ".$id.")"; // seleciona os amigos q ele ainda nao recomendeou aquele jogo
                        
                          $result = pg_query($sql);
                        ?>
                    <table border="0" width="100%" align="center" style="border: 1px solid #ccc;">
                    <tbody>
                            <tr align="center" style="border: 1px solid #ccc;">
                            <td colspan="2" align="center" ><strong>Amigos</strong></td>
                            
                        </tr>
                    

                        <?php 
                        if(pg_num_rows($result) == 0){
                        ?>
                        <tr style="border: 1px solid #ccc;">
                            <td align="center" colspan="2" style="border: 1px solid #ccc;">
                            <strong>NAO HÁ AMIGOS PARA RECOMENDAR!</strong>
                            </td>
                        </tr>    
                            
                        <?
                            
                            
                            
                        }
                        else {
                        
                        while ($colum = pg_fetch_array($result)) { ?>  
                        <tr style="border: 1px solid #ccc;">
                            <td align="center" style="border: 1px solid #ccc;">
                              <?php echo $colum["nome"]; ?>  
                            </td>
                            <td align="center" style="border: 1px solid #ccc;"> <a href="indexUser.php?link=8&AMP;idAmigo=<? echo $colum["codigo"];?>&AMP;idJogo=<?echo $id;?>&AMP;pagina=<?echo $_GET["pagina"];?>&AMP;caracteristica=<?echo $_GET["caracteristica"];?>&AMP;volta=<?echo $_GET["volta"];?>"> <img src="images/like.jpg" width="20" height="20" alt="add_48"/> RECOMENDAR </a></td>
                        </tr>
                         <?php } 
                         
                         } $conexao->desconectBD(); ?>
                    </tbody>
                </table>

                    </td>
                    
                </tr>
                <tr>
                    <td colspan="2" align="center"><a href="indexUser.php?link=6&AMP;id=<?echo $_GET["id"];?>&AMP;pagina=<?echo $_GET["pagina"];?>&AMP;caracteristica=<?echo $_GET["caracteristica"];?>&AMP;volta=<?echo $_GET["volta"];?>"><img src="images/icone_seta_voltar.png" width="40" height="40" alt="icone_seta_voltar"/> </br> VOLTAR</a></td>
                   
                </tr>
            </tbody>
        </table>

        
        
        
        
    </body>

</html>












<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
